package cn.com.taiji.pos.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.github.dreamyoung.mprelation.EntityMapper;
import com.github.dreamyoung.mprelation.JoinColumn;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 账户交易消费流水
 * </p>
 *
 * @author
 * @since 2021-03-01
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class TradeAccountConsumptionFlow implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "ID", type = IdType.ASSIGN_UUID)
    private String id;

    /**
     * 所属餐厅
     */
    @TableField("RESTAURANT_ID")
    private String restaurantId;

    /**
     * 所属餐次
     */
    @TableField("MEAL_TIME_ID")
    private String mealTimeId;

    /**
     * POS机
     */
    @TableField("POS_MACHINE_ID")
    private String posMachineId;

    /**
     * 所属顾客
     */
    @TableField("CUSTOMER_ID")
    private String customerId;
    @TableField(exist = false)
    @EntityMapper
//    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "ID")
    private CardCustomer customer;

    /**
     * 所属账户
     */
    @TableField("ACCOUNT_ID")
    private String accountId;

    /**
     * 刷卡卡号
     */
    @TableField("CARD_ID")
    private String cardId;

    /**
     * 操作类型(0:消费 1:消费冲账)
     */
    @TableField("OPERATE_TYPE")
    private Integer operateType;

    /**
     * 结算类型
     */
    @TableField("SETTLEMENT_TYPE_ID")
    private String settlementTypeId;

    /**
     * 流水单号
     */
    @TableField("FLOW_NO")
    private String flowNo;

    /**
     * 操作前金额
     */
    @TableField("BEFORE_AMOUNT")
    private BigDecimal beforeAmount;

    /**
     * 操作(增减)金额
     */
    @TableField("ACTUAL_AMOUNT")
    private Double actualAmount;

    /**
     * 操作后金额
     */
    @TableField("AFTER_AMOUNT")
    private BigDecimal afterAmount;

    /**
     * 折扣金额
     */
    @TableField("DISCOUNT_AMOUNT")
    private Double discountAmount = 0.0;

    /**
     * 操作前次数
     */
    @TableField("BEFORE_TIMES")
    private Integer beforeTimes;

    /**
     * 操作(增减)次数
     */
    @TableField("TIMES")
    private Integer times;

    /**
     * 操作后次数
     */
    @TableField("AFTER_TIMES")
    private Integer afterTimes;

    /**
     * 操作原因(冲账用)
     */
    @TableField("REASON_ID")
    private String reasonId;

    /**
     * 是否开具发票(0:否1:是)
     */
    @TableField("IS_PAY")
    private String isPay;

    /**
     * 创建人(操作人)
     */
    @TableField("CREATOR_ID")
    private String creatorId;

    /**
     * 创建人姓名
     */
    @TableField("CREATOR_NAME")
    private String creatorName;

    /**
     * 创建时间
     */
    @TableField("CREATE_TIME")
    private LocalDateTime createTime;

    /**
     * 是否导出xml(0:否1:是)
     */
    @TableField("XML_OUT")
    private String xmlOut = "0";

    private String defer;

    private LocalDateTime deferTime;

    @TableField("RETURN_PLEDGE")
    private BigDecimal returnPledge;

    @TableField("IS_OVER")
    private String isOver;

    private LocalDateTime bakCreateTime;


    private String orderStatus = "1";

    @TableField(exist = false)
    private String tableNo;
    @TableField(exist = false)
    private String mealCode;
    @TableField(exist = false)
    private String customerName;
    @TableField(exist = false)
    private Double quantity;
    @TableField(exist = false)
    private Double maxAllowance = 0d;//单餐最大优惠金额
    private transient SystemPrinter stickerPrinter;

}
